/*
* @Author: sc
* @Date:   2019-01-08 00:12:41
* @Last Modified by:   sc
* @Last Modified time: 2019-01-14 15:12:03
*/
import React 					from 'react'
import { observer, inject} 		from 'mobx-react';
import { Link } 				from 'react-router-dom';

import './index.css'

@inject('store')
@observer
class Pagination extends React.Component{
	constructor(props){
		super(props);
		// 设置页数
		if(this.props.pageSize){
			this.props.store.setPageSize(this.props.pageSize);
		}
	}
	render(){
		return(
			<div className="pagination" name={this.props.store.updatePageKey}>
				<Link to={"pageNum=" + this.props.store.getPrevPageNum} className="prev">
					<span className="pg-item" onClick={() => this.props.store.prev()}>上一页</span>
				</Link>
				<span>{this.props.store.getCurrentPage}/{this.props.store.getTotalPages}</span>
				<Link to={"pageNum=" + this.props.store.getNextPageNum} className="next">
					<span className="pg-item" onClick={() => this.props.store.next()}>下一页</span>
				</Link>
			</div>
		);
	}
}

export default Pagination;